package com.act.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import com.act.dao.ISumweekDao;
import com.act.domain.Sumweek;
import com.act.dto.PagerDTO;
import com.act.service.api.ISumweekService;
import com.act.vo.PagerVo;

@Service
public class SumweekServiceImpl implements ISumweekService{
	
	@Resource
	private ISumweekDao weekclearDao ;

	@Override
	public void add(Sumweek sumweek) {
		weekclearDao.add(sumweek);
	}

	@Override
	public void update(Sumweek sumweek) {
		weekclearDao.update(sumweek);
	}

	@Override
	public void delete(int id) {
		weekclearDao.delete(id);
	}

	@Override
	public PagerVo<Map> getAllList(@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		List<Map> list = weekclearDao.getAll(startIndex, endIndex);
		int totalCounts = weekclearDao.getCounts();
		
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);
		
		return pagerVo;
	}

	@Override
	public Sumweek getById(@Param("id")int id) {
		return weekclearDao.getById(id);
	}

	@Override
	public PagerVo<Map> getByEidTime(@Param("jobnum")String jobnum,@Param("startTime")String startTime,@Param("endTime")String endTime,@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		int totalCounts = weekclearDao.getCountsByThree(jobnum, startTime, endTime);
		List<Map> lists = weekclearDao.getByEidTime(jobnum, startTime, endTime, startIndex, endIndex);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,lists);
		
		return pagerVo;
	}

}
